package com.ardf.mapper;

import com.ardf.entity.Card;
import com.ardf.entity.Print;
import com.ardf.entity.ReplaceCard;
import com.ardf.entity.dto.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ShiYunHao
 * @since 2025-01-06
 */
public interface CardMapper extends BaseMapper<Card> {
    /**
     * 获取单位目录
     * @param competitionId
     * @return
     */
    List<UnitMenuDto> getMenu(@Param("competitionId") Long competitionId);
    /**
     *制卡分页
     */
    Page<CardSearchAllDto> searchAll(@Param("page") Page<NumberSearchAllDto> page,
                                     @Param("unitId") Long unitId,
                                     @Param("searchAll") String searchAll);

    /**
     *补卡分页
     */
    Page<ReplaceCardTableDto> replaceCardSearchAll(Page<NumberSearchAllDto> page,@Param("competitionId")  Long competitionId,@Param("searchAll")  String searchAll);

    List<CardDto> selectCardByComId(@Param("competitionId")Long competitionId,@Param("number") String number);

    /**
     * author:容伟洪
     * time:2025-2-24
     * description：根据指卡号和项目id查询选手id
     */
    Card selectAthleteIdByNumAndPId(@Param("number")String number,@Param("projectId") Long projectId);

    /**
     * author:容伟洪
     * time:2025-3-8
     * description：像补卡表插入一条补卡信息
     */
    Integer insertReplaceCard(CardDto dto);

    /**
     * author:容伟洪
     * time:2025-3-8
     * description：根据赛事Id查询是否有当前指卡的补卡记录
     */
    List<CardDto> selectReplaceCardAll(@Param("competitionId") Long competitionId,
                                       @Param("number")String number);

    /**
     * author:容伟洪
     * time:2025-3-8
     * description：根据选手Id查询所有的补卡记录
     */
    List<CardDto> selectReplaceCardByAthId(@Param("athleteId") Long athleteId);

    /**
     * author:容伟洪
     * time:2025-3-8
     * description：根据选手Id和指卡号查询是否有补卡记录
     */
    ReplaceCard selectReplaceCardByComId(@Param("competitionId") Long competitionId,
                                         @Param("number")String number);
    void deleteByAthId(@Param("athleteId") List<Long> athleteIds);

    void deleteByComId(@Param("competitionId") Long competitionId);

    /**
     * author:容伟洪
     * time:2025-3-12
     * description：根据指卡选手id查找当前选手的信息
     */
    Print selectPrintByAthId(@Param("athId") Long athId);

    /**
     * author:容伟洪
     * time:2025-3-15
     * description：根据指卡id查找当前选手的信息
     */
    Print selectPrintById(@Param("id") Long id);
}
